import theme from "../theme/index.js";
import music from "../music/index.js";
import tool from "../tool/index.js";

const right = {

    toHome: () => {
        // 设置路径为 '#index'
        window.location.pathname = '#index';
        // 刷新页面
        location.reload();
    },

    backward: () => {
        window.history.back();
        theme.hideRightMenu();
    },

    forward: () => {
        window.history.forward();
        theme.hideRightMenu();
    },

    refresh: () => {
        window.location.reload();
    },

    top: () => {
        theme.scrollToDest(0, 500);
        theme.hideRightMenu();
    },

    copyText: (text) => {
        tool.rightMenuCopyText(text);
        tool.snackbarShow('复制成功，复制和转载请标注本文地址');
        theme.hideRightMenu();
    },

    copyLink: (href) => {
        tool.copyLink(href);
        theme.hideRightMenu();
    },

    copyUrl: () => {
        tool.copyPageUrl();
        theme.hideRightMenu();
    },

    copyImage: (imageURL) => {
        tool.writeClipImg(imageURL);
        theme.hideRightMenu();
    },

    downloadImage: (imgSrc) => {
        tool.downloadImage(imgSrc, 'hao');
        theme.hideRightMenu();
    },

    copyMusicName: () => {
        tool.rightMenuCopyText(music.musicGetName());
        tool.snackbarShow('复制歌曲名称成功', false, 3000);
        theme.hideRightMenu();
    },

    pasteText: () => {
        tool.pasteText();
        theme.hideRightMenu();
    },

    commentText: (selectTextNow) => {
        tool.rightMenuCommentText(selectTextNow);
        theme.hideRightMenu();
    },

    newWindow: (currentHref) => {
        window.open(currentHref);
        theme.hideRightMenu();
    },

    newWindowOpenImage: (imageSrc) => {
        window.open(imageSrc, "_blank");
        theme.hideRightMenu();
    },

    baiduSearch: (text) => {
        tool.searchBaidu(text);
        theme.hideRightMenu();
    },

    musicPlayList: () => {
        window.open('https://music.163.com/#/playlist?id=5172410111');
        theme.hideRightMenu();
    },

    musicToggle: () => {
        music.musicToggle();
        theme.hideRightMenu();
    },

    backMusic: () => {
        music.musicSkipBack();
        theme.hideRightMenu();
    },

    forwardMusic: () => {
        music.musicSkipForward();
        theme.hideRightMenu();
    },

    switchThemeMode: () => {
        theme.switchThemeMode();
        theme.hideRightMenu();
    },

    switchCommentBarrage: () => {
        theme.switchCommentBarrage();
        theme.hideRightMenu();
    },

    toRandomPost: () => {
        tool.toRandomPost();
        theme.hideRightMenu();
    },

    translate: () => {
        tool.snackbarShow('暂未实现');
        theme.hideRightMenu();
    },

}

export default right;